<template>
  <div class="divBox">
    <el-card class="box-card">
      <el-form inline size="small" @submit.native.prevent>
        <el-form-item label="关键词：">
          <el-input v-model="listPram.keyword" placeholder="关键词" clearable class="selWidth"/>
        </el-form-item>
        <el-form-item label=" 支付状态:">
          <el-select v-model="listPram.state" clearable placeholder="请选择" class="selWidth">
            <el-option
                v-for="item in stateList"
                :key="item.id"
                :label="item.data"
                :value="item.id">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button icon="el-icon-search" size="mini" type="primary" @click.native="getList">搜索</el-button>
          <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
        </el-form-item>
      </el-form>
      <el-table :data="listData.list" size="mini"
                :header-cell-style=" {fontWeight:'bold',background:'#f8f8f9',color: '#515a6e',height:'40px'}" border>
        <el-table-column align="center" label="ID" prop="id" width="50"></el-table-column>
        <el-table-column align="center" label="订单号" prop="orderNo" width="150"/>
        <el-table-column align="center" label="户号" prop="account" width="100"/>
        <el-table-column align="center" label="用户姓名" prop="userName" width="100"/>
        <el-table-column align="center" label="单位名称" prop="companyName" width="200"/>
        <el-table-column align="center" label="用户详细地址" prop="userAddress" width="200"/>
        <el-table-column align="center" label="缴费金额(元)" prop="payMoney" width="120"/>
        <el-table-column align="center" label="燃气表余额(m³)" prop="gasMeterBalance" width="120"/>
        <el-table-column align="center" label="类型" prop="typeStr" width="80"/>
        <el-table-column align="center" label="状态" prop="stateStr" width="80"/>
        <el-table-column align="center" label="支付失败原因" prop="reason" width="150"/>
        <el-table-column align="center" label="创建时间" prop="createTime" width="100"/>
        <el-table-column align="center" label="操作" min-width="100" fixed="right">
          <template slot-scope="scope">
            <el-button icon="el-icon-edit" size="mini" type="primary" @click="openEdit(scope.row)"
                       v-has-permi="['admin:payment:record:detail']">详情
            </el-button>
          </template>
        </el-table-column>
      </el-table>
      <el-pagination
          :current-page="listPram.page"
          :page-sizes="[10,20,40,60,80,100]"
          layout="total, sizes, prev, pager, next, jumper"
          :total="listData.count"
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
      />
    </el-card>
    <el-dialog
        :visible.sync="editDialog.show"
        title="详情"
        destroy-on-close
        :close-on-click-modal="false"
        width="1200px">
      <edit
          v-if="editDialog.show"
          :edit-data="editDialog.editDate"
          @hideEditDialog="hideEditDialog"
          ref="editForm"
      />
    </el-dialog>
  </div>
</template>

<script>
import edit from './edit'
import {recordList} from "@/api/payment";
import {checkPermi} from "@/utils/permission";

export default {
  components: {edit},
  data() {
    return {
      listData: {
        list: [], count: 0
      },
      listPram: {
        keyword: '',
        page: 1,
        limit: 10,
      },
      editDialog: {
        show: false,
        id: null
      },
      tableLoading: false,
      stateList: [{id: 1, data: "待支付"}, {id: 2, data: "已支付"}, {id: 3, data: "支付失败"}],//1待支付 2已支付 3支付失败
    }
  },
  mounted() {
    this.getList()
  },
  methods: {
    checkPermi,
    getList() {
      this.tableLoading = true
      recordList(this.listPram).then(res => {
        this.listData = res;
      }).finally(() => {
      })
      this.tableLoading = false;
    },
    openEdit(editData) {
      this.editDialog.editDate = editData;
      this.editDialog.show = true
    },
    hideEditDialog() {
      this.editDialog.show = false
      this.getList()
    },
    handleSizeChange(val) {
      this.listPram.limit = val
      this.getList()
    },
    handleCurrentChange(val) {
      this.listPram.page = val
      this.getList()
    },
    resetQuery() {
      this.listPram.keyword = '';
      this.listPram.state = null;
      this.getList()
    }
  }
}
</script>

<style scoped lang="scss">

</style>
